package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.CommissionService;
import com.yixun.qfbao.api.service.PersonnelService;
import com.yixun.qfbao.apidto.DealCommissionReqDto;
import com.yixun.qfbao.apidto.DealCommissionResDto;
import com.yixun.qfbao.apidto.EditPartnerReqDto;
import com.yixun.qfbao.apidto.EditPartnerResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.DealCommissionReqVo;
import com.yixun.qfbao.vo.EditPartnerReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description
 * @Date 2017/11/28
 * @Author sangtao
 * @Computer Administrator
 */
@Service("dealCommissionHander")
public class DealCommissionHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(DealCommissionHander.class);
    @Autowired
    CommissionService commissionService;
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        DealCommissionReqVo req = (DealCommissionReqVo)reqDto;
        DealCommissionReqDto dealCommissionReqDto = req.getParams();
        BaseResponseDTO<DealCommissionResDto> res = new BaseResponseDTO<DealCommissionResDto>();
        DealCommissionResDto resDto = new DealCommissionResDto();
        try{
            resDto = commissionService.dealCommission(dealCommissionReqDto);
        } catch (Exception e) {
            logger.error("DealCommissionHander ==> error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("结佣失败!");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
